<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="hexinyang">
	<title>密码启用停用</title>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>	
	<script language="javascript" src="../script/card.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript" src="../script/print.js"></script>
	<script type="text/javascript">    
		//页面控件初始化
		var pageData = {usePin : null,cardPin : null}
		function load(){
			Eui.showNavigation();
			setPages(["readcardview","detview"]);
		}
		
		//读卡
		function onReadCard(){
			try{
				var data = CardMgnt.findCardNeedPin(readCardForm);
				if (!CardMgnt.checkInUseCard(data.card)) return;
				pageData.cardPin = data.cardPin;
				pageData.usePin = getNeedPin();
				$("readCardBtn").disabled = true;
				if (pageData.usePin)
					$("pinappbtn2").disabled = false;
				else
					$("pinappbtn1").disabled = false;
			}catch(e){
				showError(e.description);
			}
		}
		
		//启用停用密码
		function appPin(usePin){
			var asn = readCardForm.asn.value;
			var res
			try{	
				res = CardMgnt.usePinApp(asn,usePin,pageData.cardPin)
			}catch(e){
				showError(e.description);
				if (e.type != 'repeat')
					onCancel();
				return;
			}
			showInformation("密码"+(usePin?"启用":"停用")+"成功！");
			switchPage("detview");
			CardMgnt.showPrintView("detview","pswd_app_bill",res.logId,"密码启用停用凭证");
		}	
		
		function onCancel(){
			switchPage("readcardview");
			readCardForm.reset();
			pageData = {};
			$("readCardBtn").disabled = false;
			$("pinappbtn1").disabled = true;
			$("pinappbtn2").disabled = true;
		}
	</script>
	</head>
	<body onload="load()" onunload="releaseCard()">
		<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="readcardview">
		<div id="carddiv">
			<form name="readCardForm" id="readCardForm">
				<div class="form">
					<div class="formTitle">卡片信息</div>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label6">
						<tr>
							<td><label>卡&nbsp;&nbsp;&nbsp;&nbsp;号</label> <input type="text" name="asn" readonly class="readonly"></td>
							<td><label>有 效 期</label> <input type="text" name="expiredTime" readonly class="readonly"></td>
						</tr>
						<tr>
							<td><label>卡 类 型</label> <input type="text" name="baseCardTypeText" readonly class="readonly"></td>
							<td><label>卡子类型</label> <input type="text" name="subCardTypeText" readonly class="readonly"></td>
						</tr>	
						<tr>
							<td><label>卡片状态</label> <input type="text" name="statusText" readonly class="readonly"></td>
							<td><label>黑名单类型</label> <input type="text" name="blackTypeText" readonly class="readonly"></td>
						</tr>
					</table>
				</div>
			</form>
		</div>
		<p>
			<button id="readCardBtn" onclick="onReadCard()">读 卡</button>
			<button id="pinappbtn1" onclick="appPin(true)" disabled>启用密码</button>
			<button id="pinappbtn2" onclick="appPin(false)" disabled>停用密码</button>
			<button onclick="onCancel()">重 置</button>
		</p>
	</div>
	<div id="detview" style="display:none;">
	</div>
	</body>
</html>